<template>
  <div class="starsetting">
    <h3>制定星级评分标准</h3>
    <hr />
    <el-form :model="starsetting" :inline="true" class="demo-form-inline">
      <el-col :span="3">
        <div class="block">
          <el-rate
            v-model="starsetting.totalFirstScoring"
            style="height: 40px; padding: 10px 0"
          ></el-rate>
        </div>
      </el-col>
      <el-col :span="19">
        <el-form-item
          label="一档:"
          prop="totalFirst"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            placeholder="请输入分值"
            v-model.number="starsetting.totalFirst"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">分以上</span>
      </el-col>

      <el-col :span="3">
        <div class="block">
          <el-rate
            v-model="starsetting.totalSecondScoring"
            style="height: 40px; padding: 10px 0"
          ></el-rate>
        </div>
      </el-col>
      <el-col :span="6">
        <el-form-item
          label="二档:"
          prop="totalSecondL"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            placeholder="请输入分值"
            v-model.number="starsetting.totalSecondL"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="15">
        <el-form-item
          label="至"
          prop="totalSecondU"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            placeholder="请输入分值"
            v-model.number="starsetting.totalSecondU"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">分</span>
      </el-col>

      <el-col :span="3">
        <div class="block">
          <el-rate
            v-model="starsetting.totalThirdScoring"
            style="height: 40px; padding: 10px 0"
          ></el-rate>
        </div>
      </el-col>
      <el-col :span="19">
        <el-form-item
          label="三档:"
          prop="totalThird"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            placeholder="请输入分值"
            v-model.number="starsetting.totalThird"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">分以下</span>
      </el-col>

      <el-col :span="6">
        <el-form-item>
          <el-button type="primary" @click="starsubFun">确定</el-button>
        </el-form-item>
      </el-col>
    </el-form>
  </div>
</template>

<script>
import {
  starTotal,
  tourevaluation,
  BasicInfoscore,
  
} from "@network/api/score.js";
export default {
  data() {
    return {
      starsetting: {
        totalFirst: "",
        totalFirstId: 21,
        totalFirstScoring: "",
        totalSecondId: 22,
        totalSecondL: "",
        totalSecondScoring: "",
        totalSecondU: "",
        totalThird: "",
        totalThirdId: 23,
        totalThirdScoring: "",
      },
    };
  },
  methods: {
    async starsubFun() {
      let resstarTotal = await starTotal(this.starsetting);
      let { code } = resstarTotal.data;
      if (code && code == 200) {
        this.$message({
          message: "星级标准设置成功！",
          type: "success",
        });
      }
      console.log("resstarTotal", resstarTotal);
    },
    async tourevaluationFun() {
      let restourevaluation = await tourevaluation();
      console.log("总评价", restourevaluation);
    },
    async BasicInfoFun() {
      let resBasicInfoscore = await BasicInfoscore();
      console.log(
        "resBasicInfoscore",
        resBasicInfoscore.data.data.allEvaluation
      );
      resBasicInfoscore.data.data.allEvaluation.forEach((element) => {
        switch (element.scoringId) {
          case 21:
            this.starsetting.totalFirst = Number(element.beiyong1);
            this.starsetting.totalFirstScoring = element.scoringScore;
            break;
          case 22:
            this.starsetting.totalSecondL = Number(element.beiyong1);
            this.starsetting.totalSecondU = element.beiyong2;
            this.starsetting.totalSecondScoring = element.scoringScore;
            break;
          case 23:
            this.starsetting.totalThirdScoring = element.scoringScore;
            this.starsetting.totalThird = element.beiyong2;
            break;
        }
      });
    },
  },
  created() {
    this.tourevaluationFun();
    this.BasicInfoFun();
  },
};
</script>

<style scoped>
.starsetting {
  background-color: #fff;
  height: 100vh;
  padding: 40px 20px;
}
.spanStyle {
  margin-left: 3px;
  display: inline-block;
  height: 41px;
  line-height: 41px;
}
.demo-form-inline {
  margin-top: 30px;
}
.block {
  height: 40px;
  text-align: center;
}
</style>